interface Todo {
  title: string;
  completed: boolean;
  description: string;
}

let todoList: Todo[] = [
  {
    title: "开发权限管理模块",
    completed: true,
    description: "使用vue3+typescript来开发",
  },
  {
    title: "年会",
    completed: false,
    description: "12月29号上午开心酒店1楼105",
  },
];

// 实现
// const pickTodoList = {
//   开发权限管理模块: {
//     title: "开发权限管理模块",
//     completed: true,
//   },
//   年会: {
//     title: "年会",
//     completed: false,
//   },
// };

// 使用 reduce 来创建一个新的对象
const pickTodoList: Record<
  string,
  Pick<Todo, "title" | "completed">
> = todoList.reduce((pre, cur) => {
  pre[cur.title] = { title: cur.title, completed: cur.completed };
  return pre;
}, {} as Record<string, Pick<Todo, "title" | "completed">>);

console.log(pickTodoList);

export {};
